var express = require('express');
var router = express.Router();
var multiparty = require('multiparty');

router.post('/imgadd', async (req, res) => {
  let from = new multiparty.Form()
  from.uploadDir = 'upload'
  from.parse(req, (a, b, c) => {
    console.log(c);
    console.log(c.file[0].path);
    res.send("http://localhost:3000/" + c.file[0].path)
  })
})

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});

module.exports = router;
